package arithmetic;

/**
 * @program: javaLearn
 * @description: 删除数组中重复数字 （双指针）
 * @author: renhai
 * @Date ：2022/3/10 21:56
 **/
public class deleteRepate {

    public int removeDuplicates(int[] nums) {
        int n = nums.length;
        if (n == 0) {
            return 0;
        }
        int label1 = 1;
        int label2 = 1;
        while (label2 < n) {
            if (nums[label2 - 1] != nums[label2]) {
                nums[label1] = nums[label2];
                label1++;
            }
            label2++;
        }
        return label1;
    }
}
